package boot.spring.type.dlx.contrller;

import boot.spring.service.Publisher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

@RestController
public class DlxController {
    @Autowired
    private Publisher publisher;
    /**
     * 订单交换机
     */
    @Value("${rk.order.exchange}")
    private String orderExchange;
    /**
     * 订单路由key
     */
    @Value("${rk.order.routingKey}")
    private String orderRoutingKey;

// 延时队列
    @GetMapping("/deadLetterSendDirectMessage")
    public String deadLetterSendDirectMessage() {
        String msgId = UUID.randomUUID().toString();
        String msg = "demo msg ,dead letter!!";
        Map<String, Object> map = new HashMap();
        map.put("msgId", msgId);
        map.put("msg", msg);
        map.put("createTime", new Date());
        publisher.sendtDeadLetter(orderExchange, orderRoutingKey,map,"100000");
        return "ok";
    }
}




